package 剑指offerII;

public class _6排序数组中的两个数字之和 {
    public int[] twoSum(int[] numbers, int target) {
        int i = 0, j = numbers.length - 1;
        int[] res = new int[2];
        while (i < j){
            int sum = numbers[i] + numbers[j];
            if(sum > target){
                j--;
            }else if(sum < target){
                i++;
            }else{

                res[0] = i;
                res[1] = j;
                return res;
            }
        }
        return res;
    }
}
